chai = require 'chai'
chai.should()
sinon = require 'sinon'

{Refresh} = require "../src/refresh"
{EntrustProxy} = require '../src/entrustproxy'

describe 'is User Locked or suspended', ->
  it 'should return false if user is not locked and not suspended', ->
    entrustProxy = new EntrustProxy()
    sinon.stub(entrustProxy, 'isUserLocked').returns(false)
    sinon.stub(entrustProxy, 'isUserSuspended').returns(false)
    refresh = new Refresh(null, null, entrustProxy)
    refresh.isUserLockedOrSuspended('JoeUser').should.be.false

  it 'should return true if user is locked and not suspended', ->
    entrustProxy = new EntrustProxy()
    sinon.stub(entrustProxy, 'isUserLocked').returns(true)
    sinon.stub(entrustProxy, 'isUserSuspended').returns(false)
    refresh = new Refresh(null, null, entrustProxy)
    refresh.isUserLockedOrSuspended('JoeUser').should.be.true

  it 'should return true if user is suspended and not locked', ->
    entrustProxy = new EntrustProxy()
    sinon.stub(entrustProxy, 'isUserLocked').returns(false)
    sinon.stub(entrustProxy, 'isUserSuspended').returns(true)
    refresh = new Refresh(null, null, entrustProxy)
    refresh.isUserLockedOrSuspended('JoeUser').should.be.true